define(['jquery' ], ()=> {
    class Header{
     constructor(){
         this.loadHTML().then(()=>{
            this.calcCartCount()
         })
         
     }
     loadHTML(){
         return new Promise((resolve,reject)=>{
            $('header').load('/html/modules/header.html',()=>{
                resolve()
            })
            
        }) 
     }
     calcCartCount(){
        let count=0
        let cart =localStorage.getItem('cart')
        if(cart){
            cart=JSON.parse(cart)
            count=cart.reduce((num,shop)=>{
                num +=shop.count
                return num
            },0)
        }
        $('#shopnum').html(count)
        $('#shopcartnum').html(count)
     }
    }
     return new Header()
 })